home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_100 / 130_01 / vmain.c < prev    next >
Text File  |  1985-03-09  |  1KB  |  52 lines

  1. #include <vbuf.h>
  2.  
  3.  
  4. main()
  5. {
  6.     char vbuf[VBUFSIZ],str[256],buf[256];
  7.     int b,c;
  8.     char a;
  9.  
  10.  
  11.     puts("\n\nVFILE TEST PROGRAMME\n\n\n");
  12.     puts("Name of file  ");
  13.     gets(str);
  14.     puts("record length: ");
  15.     scanf("%d",&b);
  16. printf("number=%d\n",b);
  17.     if(vopen(str,vbuf,b)==ERROR) 
  18.     {    if (vcreat(str,vbuf,b)==ERROR)
  19.     {puts("cannot open...\n"); exit();}
  20.     }
  21.     while(1)
  22.     {
  23.       puts("\n#");
  24.       a=toupper(getchar());
  25.         if (a=='X')
  26.          {vclose(vbuf); puts("x"); exit();}
  27.  
  28.         if (a=='W')
  29.         {
  30.         puts("Write string: ");
  31.         gets(str);
  32.         fillb(buf,250,32,1);
  33.         strcpy(buf,str);
  34.         puts("to record #:  ");
  35.         scanf("%d",&b);
  36. printf("number=%d\n",b);
  37. printf("returned %d\n",vwrite(b,vbuf,buf));
  38.         }
  39.         else
  40.         {    
  41.         fillb(str,200,32,1);
  42.         puts("Read record #: ");
  43.         scanf("%d",&c);
  44. printf("number=%d\n",c);
  45.         printf("return %d\n",vread(c,vbuf,str));
  46.         printf("Record %d:\"%s\"\n",c,str);
  47.         }
  48.     }
  49.  
  50.     puts("How the hell d'we get here?");
  51. }
  52.